#@embedLayout()


#define content()

<div class="easyui-layout" data-options="fit:true">
    <div data-options="region:'center',border:true">
        <div id="vendorDatagridId"></div>

        <div id="vendorDatagridTb">
            <div class="row">
                <!--<div class="col-md-12">-->
                    <!--<form id="vendorSearchForm">-->
                        <!--<div class="easyui-panel" style="width:100%;padding:10px;"-->
                             <!--data-options="iconCls:'icon-application_form'">-->

                            <!--&lt;!&ndash;厂商：&ndash;&gt;-->
                            <!--<select id="deviceType" name="deviceType" class="easyui-combobox" data-options="editable: false">-->
                                <!--<option value="ALL" selected>全部</option>-->
                                <!--#for(vendor : vendorList)-->
                                <!--<option value="#(vendor.venId)">#(vendor.vendorName)</option>-->
                                <!--#end-->
                            <!--</select>&nbsp;&nbsp;-->
                            <!--&lt;!&ndash;型号：&ndash;&gt;-->
                            <!--<select name="deviceName" id="deviceName" class="easyui-combobox" data-options="editable: false">-->
                                <!--<option value="ALL" selected>全部</option>-->
                                <!--#for(deviceName : deviceNames)-->
                                <!--<option value="#(deviceName)">#(deviceName)</option>-->
                                <!--#end-->
                            <!--</select>-->

                            <!--&lt;!&ndash;<a href="javascript:;" class="easyui-linkbutton" data-options="plain:true"&ndash;&gt;-->
                               <!--&lt;!&ndash;onclick="vendorDatagridQuery();"&ndash;&gt;-->
                               <!--&lt;!&ndash;iconCls="icon-zoom">#(_res.get('system.common.search'))</a>&ndash;&gt;-->
                            <!--&lt;!&ndash;<a href="javascript:;" class="easyui-linkbutton" data-options="plain:true"&ndash;&gt;-->
                               <!--&lt;!&ndash;onclick="$('#vendorSearchForm').form('clear');"&ndash;&gt;-->
                               <!--&lt;!&ndash;iconCls="icon-zoom_out">#(_res.get('system.common.clear'))</a>&ndash;&gt;-->
                        <!--</div>-->
                    <!--</form>-->
                <!--</div>-->
                <div class="row">
                    <div class="col-md-12" style="padding: 5px 25px;">
                        <a href="javascript:;" class="easyui-linkbutton"
                           data-options="iconCls:'icon-application_add',plain:true"
                           id="versionAdd">增加版本</a>

                        <a href="javascript:;" class="easyui-linkbutton"
                           data-options="iconCls:'icon-application_edit',plain:true"
                           id="versionEdit">编辑版本</a>

                        <a href="javascript:;" class="easyui-linkbutton"
                           data-options="iconCls:'icon-application_delete',plain:true"
                           id="versionRemove">删除版本</a>

                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

#end


#define css()


#end


#define js()

<script type="text/javascript">
    var vendorDatagridId = "vendorDatagridId", vendorFormId = "vendorFormId", vendorDatagridTb = "vendorDatagridTb";
    var vendorDatagridListUrl = contextRootPath + '/equipment/deviceVersionList';

    $(function () {
        //初始化表格
        $("#" + vendorDatagridId).datagrid({
            url: vendorDatagridListUrl,
            fit: true,
            border: false,
            rownumbers: true,
            pageSize: 30,
            toolbar: '#' + vendorDatagridTb,
            singleSelect: false,
            pagination: true,
            nowrap: false,
            striped: true,
            fitColumns: true,
            columns: [[
                {   field: "equ_version_id",
                    title: "equ_version_id",
                    width: 150,
                    checkbox: true
                }, {
                    field: DBConts.TABLE_VENDOR.VENDOR_NAME,
                    title: '厂商名称',
                    sortable: false
                }, {
                    field: DBConts.TABLE_EQUIPMENT.EQU_MODEL,
                    title: '设备型号',
                    sortable: false
                }, {
                    field: "equ_version",
                    title: '设备版本',
                    sortable: false
                }
            ]]
        });


        $("#versionAdd").on('click', function () {
            var params = {};
            params.dlgId = 'vendor_crud_dlg';
            params.title = '增加版本';
            params.width = 700;
            params.height = 250;
            params.top = '40px';
            params.modal = true;
            params.iconCls = 'icon-shape_ungroup';
            params.url = contextRootPath + '/equipment/versionAdd';
            params.buttons = [{
                text: '提交',
                iconCls: 'icon-application_go',
                handler: function () {
                    vendor_datagrid_save('add');
                }
            }, {
                text: '重置',
                iconCls: 'icon-application_side_contract',
                handler: function () {
                    clearForm('vendorFormId')
                }
            }];

            crud_dlg(params);
        });


        $("#versionEdit").on('click', function () {
            var selected = $('#' + vendorDatagridId).datagrid('getSelected');

            if (selected === null) {
                $.messager.alert("提示框", "请选择需要操作的版本!", "warning");
                return;
            }

            var selections = $('#' + vendorDatagridId).datagrid('getSelections');

            if (selections.length < 1) {
                $.messager.alert("提示框", "请选择需要操作的版本!", "warning");
                return;
            } else if (selections.length > 1) {
                $.messager.alert("提示框", "编辑的版本为多个，请重新选择!", "warning");
                return;
            }

            var params = {};
            params.dlgId = 'vendor_crud_dlg';
            params.title = '编辑版本';
            params.width = 700;
            params.height = 250;
            params.top = '40px';
            params.modal = true;
            params.iconCls = 'icon-application_edit';
            params.url = contextRootPath + '/equipment/versionEdit/' + selected['equ_version_id'];
            params.buttons = [{
                text: '提交',
                iconCls: 'icon-application_go',
                handler: function () {
                    vendor_datagrid_save();
                }
            }, {
                text: '关闭',
                iconCls: 'icon-application_side_contract',
                handler: function () {
                    $('#vendor_crud_dlg').dialog('close');
                }
            }];

            crud_dlg(params);
        });


        $("#versionRemove").on('click', function () {
            var selections = $('#' + vendorDatagridId).datagrid('getSelections');
            var ids = "";
            var names = "";

            if (selections.length < 1) {
                $.messager.alert("提示框", "请选择需要操作的版本!", "warning");
                return;
            }

            $.messager.confirm('确认框', '请确定需要删除所选择的版本么？', function (r) {
                if (r) {
                    $.each(selections, function (i, v) {
                        ids += v['equ_version_id'] + ",";
                        names += v['equ_version'] + ",";
                    });

                    $.post(contextRootPath + "/equipment/versionRemove?versionId=" + ids +"&deviceVersion=" +names, function (data) {
                        var params = {};
                        params.element = vendorDatagridId;
                        params.data = data;
                        params.isClose = false;
                        resultCallback(params);
                    }, 'json');
                }
            });

        });
    });


    function vendorDatagridQuery() {
        var vendorName = $("#vendorName");
        var vendorAlias = $("#vendorAlias");

        var flag = $("#vendorSearchForm").form('enableValidation').form('validate');
        if (!flag) return;

        $("#" + vendorDatagridId).datagrid({
            queryParams: {
                "vendor.vendor_name": vendorName.val(),
                "vendor.vendor_alias": vendorAlias.val()
            }
        });
    }

    $("#deviceType").combobox({
        onSelect:function (selectObj) {
            getDeviceNameAlias(selectObj.value);
        }
    });

    function getDeviceNameAlias(venId) {

        $("#deviceName").combobox({
            url: contextRootPath + "/equipment/getEquipments?venId="+venId,
            method: 'get',
            valueField: 'deviceNameAlias',
            textField: 'deviceNameAliasDesc',
            panelHeight: 'auto',
            width:'100px',
            editable: false
        });
    }

</script>

#end


